package com.ruoyi.system.service.impl;

import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.domain.TbDiscountCondition;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.apache.commons.lang3.StringUtils;
import com.ruoyi.system.mapper.TbGoodsMapper;
import com.ruoyi.system.domain.TbGoods;
import com.ruoyi.system.service.ITbGoodsService;

import java.util.List;
import java.util.Map;

/**
 * 商品设置Service业务层处理
 *
 * @author ruoyi
 * @date 2021-02-19
 */
@Service
public class TbGoodsServiceImpl extends ServiceImpl<TbGoodsMapper, TbGoods> implements ITbGoodsService {

    @Override
    public List<TbGoods> queryList(TbGoods tbGoods) {
        LambdaQueryWrapper<TbGoods> lqw = Wrappers.lambdaQuery();

            //查询对应的userId
            lqw.eq(TbGoods::getUserId, SecurityUtils.getLoginUser().getUser().getUserId());


        if (StringUtils.isNotBlank(tbGoods.getName())){
            lqw.like(TbGoods::getName ,tbGoods.getName());
        }
        if (StringUtils.isNotBlank(tbGoods.getGoodsTitle())){
            lqw.eq(TbGoods::getGoodsTitle ,tbGoods.getGoodsTitle());
        }
        if (tbGoods.getMoney() != null){
            lqw.eq(TbGoods::getMoney ,tbGoods.getMoney());
        }
        if (StringUtils.isNotBlank(tbGoods.getImages())){
            lqw.eq(TbGoods::getImages ,tbGoods.getImages());
        }
        return this.list(lqw);
    }

    @Override
    public List<TbGoods> queryLists(TbGoods tbGoods) {
        LambdaQueryWrapper<TbGoods> lqw = Wrappers.lambdaQuery();
        return this.list(lqw);
    }
}
